﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="wfKPIMonitor.aspx.cs" Inherits="Dragon.wfKPIMonitor" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
    .auto-style4 {
    }
    .auto-style5 {
            width: 108px;
        }
    .auto-style6 {
        text-align: center;
        }
    .auto-style7 {
        width: 64px;
    }
        .auto-style8 {
            width: 85px;
        }
        .auto-style9 {
            width: 100%;
            border: 2px solid #0000FF;
        }
        .auto-style11 {
            width: 98px;
        }
        .auto-style15 {
            width: 153px;
        }
        .auto-style16 {
            width: 84px;
        }
        .auto-style17 {
            width: 110px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">    
    <table class="auto-style9" style="border-color: #666633">        
        <tr>
            <td class="auto-style8">Từngày</td>
            <td class="auto-style7">
                <asp:TextBox ID="txtFromDate" runat="server" Width="100px">01/06/2015</asp:TextBox>
                <cc1:CalendarExtender ID="txtFromDate_CalendarExtender" runat="server" BehaviorID="txtFromDate_CalendarExtender" TargetControlID="txtFromDate" Format="dd/MM/yyyy" />
            </td>
            <td class="auto-style5">Đến ngày</td>
            <td class="auto-style17">
                <asp:TextBox ID="txtToDate" runat="server" Width="100px">30/06/2015</asp:TextBox>
                <cc1:CalendarExtender ID="txtToDate_CalendarExtender" runat="server" BehaviorID="txtToDate_CalendarExtender" TargetControlID="txtToDate" Format="dd/MM/yyyy" />
            </td>
            <td class="auto-style16">
                Tỉnh thành</td>
            <td class="auto-style11">
                <cc1:ComboBox ID="ddlProvince" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="Code" DropDownStyle="DropDownList" MaxLength="0" style="display: inline; text-align: left;" Width="150px" OnDataBound="ProvinceOnDataBound" AutoPostBack="True">
                </cc1:ComboBox>
            </td>
            <td class="auto-style11">
                CVTC SR</td>
            <td class="auto-style15">
                <cc1:ComboBox ID="ddlCVTCSR" runat="server" DataSourceID="SqlDataSource1" DataTextField="Fullname" DataValueField="Code" DropDownStyle="DropDownList" MaxLength="0" style="display: inline; text-align: left;" Width="150px" OnDataBound="ddlCVTCSR_DataBound">
                </cc1:ComboBox>
            </td>
            <tr>
            <td class="auto-style6" colspan="8">
                <asp:Button ID="btnRunReport" runat="server" style="text-align: center" Text="Xem kết quả" OnClick="btnRunReport_Click" />
                <asp:Button ID="btnExportExcel" runat="server" OnClick="btnExportExcel_Click" Text="Xuất Excel" />
                <asp:Button ID="btnUpdateKPI" runat="server" OnClick="btnUpdateKPI_Click" Text="Cập nhật số liệu" />
            </td>
        </tr>
        <tr>
            <td class="auto-style4" colspan="8">                
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" AllowSorting="True">
                    <Columns>
                        <asp:TemplateField HeaderText="Mã vùng" SortExpression="RegionCode">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("RegionCode") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("RegionCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="UserCode" HeaderText="Mã SR" SortExpression="UserCode" />
                        <asp:BoundField DataField="UserName" HeaderText="Tên SR" SortExpression="UserName">
                             <ItemStyle Width="180px"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="Location" HeaderText="Địa bàn" SortExpression="Location" />
                        <asp:BoundField DataField="Visited" HeaderText="Số thăm viếng" SortExpression="Visited">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W1" HeaderText="W1" SortExpression="W1" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W2" HeaderText="W2" SortExpression="W2" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W3" HeaderText="W3" SortExpression="W3" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W4" HeaderText="W4" SortExpression="W4" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W5" HeaderText="W5" SortExpression="W5" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W6" HeaderText="W6" SortExpression="W6" >
                         <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W7" HeaderText="W7" SortExpression="W7" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="W8" HeaderText="W8" SortExpression="W8" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Valid" HeaderText="Số hợp lệ" SortExpression="Valid" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="WorkingDay" HeaderText="Ngày làm việc" SortExpression="WorkingDay" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="DayOff" HeaderText="Ngày nghỉ" SortExpression="DayOff" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ActualWorkingDay" HeaderText="Ngày công" SortExpression="ActualWorkingDay" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Average" HeaderText="Trung bình" SortExpression="Average" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Bonus" HeaderText="Tiền thưởng" SortExpression="Bonus" >
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
    </table>  
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" SelectCommand="SELECT [User].Code, [User].Fullname, [User].UserType FROM Province INNER JOIN Region ON Province.Code = Region.Province INNER JOIN [User] ON Region.Code = [User].Region WHERE (Province.Code = @Province) AND ([User].UserType = N'SR') ORDER BY [User].Fullname">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlProvince" Name="Province" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" SelectCommand="SELECT * FROM [Province] WHERE ([Status] = @Status)">
        <SelectParameters>
            <asp:Parameter DefaultValue="1" Name="Status" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CarlsbergConnectionString %>" SelectCommand="SELECT * FROM [ReportKPIMonitor]"></asp:SqlDataSource>

    </asp:Content>
